package com.hzh.util

import org.wltea.analyzer.core.{IKSegmenter, Lexeme}

import java.io.StringReader
import scala.collection.mutable.ListBuffer

object IKUtil {

  def fit(text:String):List[String]={

    val listBuffer = new ListBuffer[String]

    val sr = new StringReader(text)
    val ik = new IKSegmenter(sr, true)
    var lex: Lexeme = ik.next()

    while (lex != null){
      listBuffer += lex.getLexemeText
      lex = ik.next()
    }
    listBuffer.toList
  }

  def main(args: Array[String]): Unit = {

    val text = "我刚刚更换了微博封面图，你的封面由你做主，大家快来个性化你的专属封面吧！"
    val strings: List[String] = fit(text)
    println(strings)

  }
}
